home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / flilib.zip / FLISRC.ZIP / BRUN.C < prev    next >
C/C++ Source or Header  |  1989-11-17  |  2KB  |  93 lines

  1.  
  2. #include "aai86.h"
  3. #include "aaflisav.h"
  4. #include "aafii.h"
  5.  
  6.  
  7. static char *
  8. fii_brun_comp_line(s1, cbuf, count)
  9. Pixel *s1, *cbuf;
  10. int count;
  11. {
  12. int wcount;
  13. register char *c;
  14. register int bcount;
  15. int op_count;
  16. char *start_dif;
  17. int dif_count;
  18. int same_count;
  19.  
  20. c = cbuf+1;
  21. op_count = 0;
  22. start_dif = s1;
  23. dif_count = 0;
  24. for (;;)
  25.     {
  26.     if (count < 3)
  27.         {
  28.         dif_count += count;
  29.         while (dif_count > 0)
  30.             {
  31.             bcount = (dif_count < FLI_MAX_RUN ? dif_count : FLI_MAX_RUN );
  32.             *c++ = -bcount;
  33.             dif_count -= bcount;
  34.             while (--bcount >= 0)
  35.                 *c++ = *start_dif++;
  36.             op_count++;
  37.             }
  38.         *cbuf = op_count;
  39.         return(i86_norm_ptr(c));
  40.         }
  41.     else
  42.         {
  43.         bcount = (count < FLI_MAX_RUN ? count : FLI_MAX_RUN );
  44.         if ((wcount = i86_bsame(s1, bcount)) >= 3)
  45.             {
  46.             while (dif_count > 0)
  47.                 {
  48.                 bcount = (dif_count < FLI_MAX_RUN ? dif_count : FLI_MAX_RUN );
  49.                 *c++ = -bcount;
  50.                 dif_count -= bcount;
  51.                 while (--bcount >= 0)
  52.                     *c++ = *start_dif++;
  53.                 op_count++;
  54.                 }
  55.             *c++ = wcount;
  56.             *c++ = *s1;
  57.             op_count++;
  58.             s1 += wcount;
  59.             count -= wcount;
  60.             start_dif = s1;
  61.             }
  62.         else
  63.             {
  64.             dif_count++;
  65.             s1++;
  66.             count -= 1;
  67.             }
  68.         }
  69.     }
  70. }
  71.  
  72.  
  73. Cbuf *fii_brun(Pixel *s1,Pixel *s2,USHORT *cbuf,int width,int height)
  74. {
  75. register char *c;
  76. char *oc;
  77. long total = 0;
  78.  
  79. /* store offset of 1st real line and set up for main line-at-a-time loop */
  80. c = (char *)(cbuf);
  81. while (--height >= 0)
  82.     {
  83.     oc = c;
  84.     c = fii_brun_comp_line(s1,c,width);
  85.     total += i86_ptr_to_long(c) - i86_ptr_to_long(oc);
  86.     if (total >= 60000L)
  87.         return(NULL);
  88.     s1 += width;
  89.     }
  90. return(i86_enorm_ptr(c));
  91. }
  92.  
  93.